<?php
/**增值服务控制器*/
namespace App\Http\Controllers;

use App\Http\Models\Extra;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Input;

class ExtraController extends Controller
{
    public $user = null;
    public $order = null;
    public $addr = null;
    public $extra = null;

    public function __construct()
    {
        $this->nav = '增值服务';
        $this->extra = new Extra();
    }

    /**室内设计*/
    public function interior_design()
    {
        $param = array();
        $this->user = DB::table('frontusers')->find(session('user')->id);
        $param['cart'] = CommonController::shopcart(session('user')->id);

        return view('extra.interior_design',['user'=>$this->user,'param'=>$param,'nav'=>$this->nav]);
    }
    /**室内设计数据接收*/
    public function interior_design_data()
    {
        $table = 'interior_design';
        $data = [
            'userid' => session('user')->id,
            'design_name' => trim(Input::get('design_name')),
            'design_type' => trim(Input::get('design_type')),
            'design_space' => trim(Input::get('design_space')),
            'design_amount' => trim(Input::get('design_amount')),
            'design_require' => trim(Input::get('design_require')),
            'design_status' => 0,
            'created_at' => date('Y-m-d H:i:s',time()),
            'updated_at' => date('Y-m-d H:i:s',time())
        ];
        $res =  $this->extra->insertdata($table,$data);
        if($res>0){
            return back()->withErrors('我们已经收到你的需求请耐心等待!')->withInput();
        }
    }

    /**私人定制*/
    public function customized()
    {
        $param = array();
        $this->user = DB::table('frontusers')->find(session('user')->id);
        $param['cart'] = CommonController::shopcart(session('user')->id);

        return view('extra.customized',['user'=>$this->user,'param'=>$param,'nav'=>$this->nav]);
    }

    /**私人定制数据接受*/
    public function customized_data()
    {
        $table = 'customized';
        $data = [
            'userid' => session('user')->id,
            'customized_size' => trim(Input::get('customized_size')),
            'customized_color' => trim(Input::get('customized_color')),
            'customized_num' => trim(Input::get('customized_num')),
            'customized_use' => trim(Input::get('customized_use')),
            'customized_require' => trim(Input::get('customized_require')),
            'customized_status' => 0,
            'created_at' => date('Y-m-d H:i:s',time()),
            'updated_at' => date('Y-m-d H:i:s',time())
        ];
        $res =  $this->extra->insertdata($table,$data);
        if($res>0){
            return back()->withErrors('我们已经收到你的需求请耐心等待!')->withInput();
        }
    }

    /**搬家服务*/
    public function move_server()
    {
        $param = array();
        $this->user = DB::table('frontusers')->find(session('user')->id);
        $param['cart'] = CommonController::shopcart(session('user')->id);

        return view('extra.move_server',['user'=>$this->user,'param'=>$param,'nav'=>$this->nav]);
    }

    /**搬家服务数据接收*/
    public function move_server_data()
    {
        $table = 'move_server';
        $data = [
            'userid' => session('user')->id,
            'move_name' => trim(Input::get('move_name')),
            'move_phone' => trim(Input::get('move_phone')),
            'move_email' => trim(Input::get('move_email')),
            'move_addr' => trim(Input::get('move_addr')),
            'move_require' => trim(Input::get('move_require')),
            'move_status' => 0,
            'created_at' => date('Y-m-d H:i:s',time()),
            'updated_at' => date('Y-m-d H:i:s',time())
        ];
        $res =  $this->extra->insertdata($table,$data);
        if($res>0){
            return back()->withErrors('我们已经收到你的需求请耐心等待!')->withInput();
        }
    }

}
